import json
import os

root = 'data/original-microblog/'
files = os.listdir(root)
out = open('data/CED_dataset.csv', 'w', encoding='utf-8')
out.write('label_review\n')
for file in files:
    if file.endswith('json'):
        with open(os.path.join(root, file), encoding='utf-8') as f:
            line = f.read()
            line = line.replace('_', '')
            d = json.loads(line)
            text = d['text']
            if int(file.split('_')[0])>2600:
                label = '1'
            else:
                label = '0'
            out.write(label)
            out.write('_')
            out.write(text)
            out.write('\n')
            f.close()
out.close()